@include('admin.header')
  
  <body>
    <div class="x-body">
        <form class="layui-form">
            <input type="hidden" name="nav_id" value="{{$nav->nav_id}}">
          <div class="layui-form-item">
              <label for="nav_name" class="layui-form-label">
                  <span class="x-red">*</span>导航名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="nav_name" name="nav_name" 
                  autocomplete="off" value="{{$nav->nav_name}}" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="nav_url" class="layui-form-label">
                  <span class="x-red">*</span>导航路径
              </label>
              <div class="layui-input-inline">
                  <input type="text" value="{{$nav->nav_url}}" id="nav_url" name="nav_url" 
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="nav_ord" class="layui-form-label">
                  <span class="x-red">*</span>导航排序
              </label>
              <div class="layui-input-inline">
                  <input type="number" value="{{$nav->nav_ord}}" id="nav_ord" name="nav_ord" 
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  保存
              </button>
          </div>
      </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;

          //监听提交
          form.on('submit(add)', function(data){
            console.log(data);
            $.ajax({
                url:'/admin/todo_editnav',
                type:'post',
                data:data.field,
                dataType:"json",
                success:function(res){
                    if(res.code==1){
                        layer.alert(res.msg, {icon: 6},function () {
                            parent.location.reload();
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                        });
                        
                    }else{
                        layer.alert(res.msg);
                    }
                }
            })
           
            //发异步，把数据提交给php
            return false;
          });
          
          
        });
    </script>
  </body>

</html>